
import os
import sys
import shutil
print("Hello new world")
def find_source(dir = ".", type_list = []):
    ret = []
    os_walks = os.walk(dir)
    for (root, dirs, files) in os_walks:
        for file in files:
            (file_name, file_ext) = os.path.splitext(file)
            if file_ext in type_list:
                file_path = os.path.join(root, file)
                ret.append(file_path)
    return ret

def output_ret(file_list = []):
    out_string = "[" + "\r\n"
    for file in file_list:
        out_string = out_string + '"' + file + '"' + ",\r\n"
    out_string = out_string + "]"
    print(out_string)
 
if __name__ == "__main__":
    # dir = sys.argv[1]
    # type_list = sys.argv[2:]
    dir = "./stm32l496zg_nucleo"
    type_list = [".c",".s"]
    sources = find_source(dir, type_list)

    output_ret(sources)


    
    
